#include <stdio.h>
#include <string.h>

#define STRING  "head;hello;world,;nihao;;,,;end"
int main(int argc, char *argv[])
{
    printf("str: %s\n", STRING);
    char *token;

    printf("strsep with ';'\n");
    char str[] = STRING;
    char *p = str;
    while((token = strsep(&p, ";")) != NULL) {
        printf("token: %s\n", token);
    }
    printf("p: %p\n", p);


    printf("strsep with ',;'\n");
    char str2[] = STRING;
    char *p2 = str2;
    while((token = strsep(&p2, ",;")) != NULL) {
        printf("token: %s\n", token);
    }
    printf("p: %p\n", p2);


    printf("strsep with ',;'\n");
    char str3[] = STRING;
    char *p3 = str3;
    while((token = strsep(&p3, ",;")) != NULL) {
        if (*token)
            printf("token: %s, len=%d, %d\n", token, strlen(token), p3-token);
    }
    printf("p: %p\n", p3);
}
